package com.cryann.mqttserver.exception;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author cRyann
 * @date 2018/12/24 0024 14:52
 * @description:
 */
@Aspect
@Component
@Slf4j
public class MqttExceptionAop {

//    @Pointcut(value = "@annotation(ExceptionAnn)")
//    public void exceptionHandler() {
//    }

    @Pointcut("@annotation(exceptionAnn)")
    public void serviceStatistics(ExceptionAnn exceptionAnn) {
    }

    @Before("serviceStatistics(exceptionAnn)")
    public void doBefore(JoinPoint joinPoint, ExceptionAnn exceptionAnn) {
        // 记录请求到达时间
        log.error("cy666 note:{}", exceptionAnn.value());
    }
}
